package Data;
import org.hibernate.Session;

/**
 * class the will control deleting , updating and adding new users
 * @author Erez
 *
 */

public class UserManager {
 private Session session = null;
 
 /**
  * the constructor must get a valid session in the DB, if not an exception will be thrown
  * @param session valid and active session in the DB
  */
 public UserManager(Session session) {
  if(session == null)
    throw new 
      RuntimeException("Invalid session object.");
  this.session = session;
 }
 
 /**
  * saving a new user in the DB
  * @param user the new user to be saved
  */ 
 public void saveUser(User user){
  session.save(user);
 }
 
 
 /**
  * updating a user in the DB
  * @param user the user to be updated
  */
 public void updateUser(User user){
  session.update(user);
 }
 
 
 /**
  * deleting a user in the DB
  * @param user the user to be deleted
  */
 public void deleteUser(User user) {
  session.delete(user);
 }
}
